package com.probox.common.entity.vo.im;



/**
 * 统一memberAuthToken和baseAccountToken
 */
public class Token implements java.io.Serializable {


    /**
	 *
	 */
	private static final long serialVersionUID = -7940768249892536986L;

	private Long uid;

    private String name;

    private String image;

    //角色
    private String role;

    private String token;

    private Long storeUid;



    public Long getStoreUid() {
		return storeUid;
	}


	public void setStoreUid(Long storeUid) {
		this.storeUid = storeUid;
	}


	public String getToken() {
		return token;
	}


	public void setToken(String token) {
		this.token = token;
	}


	public String getRole() {
		return role;
	}


	public void setRole(String role) {
		this.role = role;
	}


	@Deprecated
    private boolean isCustomer;

    public Token(){

    }


    public Token(long uid, String name, String image) {
        this.uid = uid;
        this.name = name;
        this.image = image;
    }
    @Deprecated
    public boolean isCustomer() {
        return isCustomer;
    }
    @Deprecated
    public void setCustomer(boolean customer) {
        isCustomer = customer;
    }

    public Long getUid() {
        return uid;
    }

    public void setUid(Long uid) {
        this.uid = uid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }



    public static Token valueOf(boolean isCustomer, Long temp) {
        Token token = new Token();
        /*
        if (isCustomer) {
            //接受用户是客服
            BaseAccountTokenService bean = SpringContextUtil.getBean(BaseAccountTokenService.class);
            BaseAccountToken byToken = bean.getUserTokenById(temp);
            token.setName(byToken.getAccountName());
            token.setUid(temp);
        } else {
            //接受用户是顾客
            MemberAuthTokenService bean = SpringContextUtil.getBean(MemberAuthTokenService.class);
            Example example = new Example(MemberAuthToken.class);
            Example.Criteria criteria = example.createCriteria();
            criteria.andEqualTo("memberUid",temp);
            criteria.andEqualTo("dataStatus","1");
            List<MemberAuthToken> list = bean.selectByExample(example,1,0);
            MemberAuthToken byMemberId = list.get(0);
            token.setUid(temp);
            token.setName(byMemberId.getMemberName());
            token.setCustomer(true);
        }*/
        return token;

    }


    @Override
    public boolean equals(Object o) {
        if (this == o){ return true;}
        if (o == null || getClass() != o.getClass()) {return false;}

        boolean t=this.isCustomer();
        boolean r=((Token)o).isCustomer();

        if(!(t&r)) {return true;}
        return false;
    }


    @Override
    public String toString() {
        return "Token{" +
                "uid=" + uid +
                ", name='" + name + '\'' +
                ", image='" + image + '\'' +
                ", isCustomer=" + isCustomer +
                '}';
    }
}
